'use strict';
app.service('authorizeService',['utilService','$q',function(utilService,$q){
    var _this_=this;

    _this_.findByPlatformWithRole = function($scope){
        var functionListVO={};
        functionListVO.roleId=$scope.roleId;
        functionListVO.platform=$scope.platform;

        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'function/role/',
            params:functionListVO
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });
        return deferred.promise;
    }

    _this_.add = function($scope){

        var roleFunction={
            functionIds:$scope.functionList,
            roleId:$scope.roleId
        }

        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'role/function',
            data:roleFunction
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }


}]);